package com.shenfc.fxzj.action.admin;

import com.shenfc.fxzj.constants.CodeConstants;
import com.shenfc.fxzj.domain.SysUser;
import org.apache.shiro.SecurityUtils;

/**
 * Created by Administrator on 2018/1/28 0028.
 */
public class BaseAction {

    /*获取session中的user的Id*/
    public Long getShiroSessionUserId() {
        SysUser sysUser = (SysUser) SecurityUtils.getSubject().getSession().getAttribute(CodeConstants.SESSION_USER);
        if (sysUser == null) {
            return 1L;
        }
        return sysUser.getId();
    }

    /*获取session中的user*/
    public SysUser getShiroSessionUser() {
        return (SysUser) SecurityUtils.getSubject().getSession().getAttribute(CodeConstants.SESSION_USER);
    }
}
